﻿
@{
    ViewData["Title"] = "BinSetAddIndex";
    Layout = null;
}

<link href="~/libs/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">库位编码</label>
        <div class="layui-input-block">
            <input type="text" id="binSetCode" name="binSetCode" lay-verify="required" placeholder="请输入库位编码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">库位名称</label>
        <div class="layui-input-block">
            <input type="text" id="binSetName" name="binSetName" lay-verify="required" placeholder="请输入库位名称" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">面积</label>
        <div class="layui-input-block">
            <input type="number" lay-affix="number" placeholder="" name="binSetCapacity" id="binSetCapacity" value="0" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">最大载重量</label>
        <div class="layui-input-block">
            <input type="number" lay-affix="number" placeholder="" name="binSetMax" id="binSetMax" value="0" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">库位位置X</label>
        <div class="layui-input-block">
            <input type="number" lay-affix="number" placeholder="" name="binSetUnitX" id="binSetUnitX" value="0" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">库位位置Y</label>
        <div class="layui-input-block">
            <input type="number" lay-affix="number" placeholder="" name="binSetUnitY" id="binSetUnitY" value="0" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">库位位置Z</label>
        <div class="layui-input-block">
            <input type="number" lay-affix="number" placeholder="" name="binSetUnitZ" id="binSetUnitZ" value="0" class="layui-input">
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label">是否启用</label>
        <div class="layui-input-block">
            <input type="radio" name="isEnable" value="true" title="是" checked>
            <input type="radio" name="isEnable" value="false" title="否">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">是否冻结</label>
        <div class="layui-input-block">
            <input type="radio" name="isFreeze" value="true" title="是" checked>
            <input type="radio" name="isFreeze" value="false" title="否">
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <button type="reset" class="layui-btn layui-btn-primary" onclick="closeWorkstation()">返回</button>
        </div>
    </div>
</form>

<script src="~/libs/layui-v2.5.6/layui/layui.js"></script>
<script src="~/libs/jquery/jquery.js"></script>
<script>
    layui.use(['form', 'laydate', 'util'], function(){
      var form = layui.form;
      var layer = layui.layer;
      var laydate = layui.laydate;
      var util = layui.util;

       // 页面加载完成后执行的函数
    $(function () {
        $('#primaryUnit').val(1);
    });


    function toggleDiv(value) {
          var additionalDiv = document.getElementById("additionalDiv");
          if (value === "是") {
              additionalDiv.style.display = "block"; // 显示DIV
          } else {
              additionalDiv.style.display = "none"; // 隐藏DIV
          }
      }



      // 提交事件
      form.on('submit(demo1)', function(data){

        var field = data.field; // 获取表单字段值

        field.isNot = Boolean(field.isNot);
        $.ajax({
            url:'/BinSet/AddBinSet',
            type:'post',
            data:field,
            dataType:'json',
            success:function(res){
                if(res.code==1){
                    layer.alert('添加成功！')
                    closeWorkstation();
                }
                if(res.code==-100){
                     layer.alert('已经有此单位名称！')

                }
            }
        })
        return false; // 阻止默认 form 跳转
      });
    });


    //关闭弹框
    function closeWorkstation() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前的索引
        parent.layer.close(index); //再执行关闭
    }

</script>

